package woniuxy.dao;


import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.FetchType;
import woniuxy.model.City;

import java.util.List;

/**
 * ClassName:CityMapper
 * Package:dao
 *
 * @date:2021/11/1 8:22 下午
 * @author: Tiangle
 */
public interface CityMapper {
    @Select("select * from city where ID = #{ID}")
    @Results(
            value = {
                    @Result(column = "CountryCode",property = "CountryCode"),
                    @Result(column = "CountryCode",property = "country",one = @One(select = "woniuxy.dao.CountryMapper.getCountry",fetchType = FetchType.DEFAULT))
            }
    )
    City getCity(int ID);//


    @Select("select * from city")
    List<City> getAll();
    @Select("select * from city where CountryCode = #{ID}")
    List<City> getCityByCountry(String ID);//根据国家查城市
}
